package site.weiyikai.eventdriven.core;

import lombok.Data;

import java.util.LinkedHashSet;
import java.util.Set;


/**
 * 事件订阅器集合
 *
 * @author 程序员小魏
 * 创建时间: 2023/11/03
 */
@Data
public class EventSubscriberSet {


    private final Set<EventSubscriber<?>> eventSubscribers = new LinkedHashSet<>();

    public EventSubscriberSet() {
    }

    public void add(EventSubscriber<?> subscriber) {
        synchronized(this.eventSubscribers) {
            this.eventSubscribers.add(subscriber);
        }
    }

    public void remove(EventSubscriber<?> subscriber) {
        synchronized(this.eventSubscribers) {
            this.eventSubscribers.remove(subscriber);
        }
    }

}
